/**
 * 
 */
package database.util;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @author Sravan
 *
 */
public class FileUtil {
	/**
	 * Create a file, overwrites the content if file already exists.
	 * @param fileName
	 * @param fileContent
	 * @throws IOException
	 */
	public static void createFileFromString(String fileName, String fileContent) throws IOException{
		BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
		bw.write(fileContent);
		bw.close();
	}
	
	/**
	 * 
	 * @param fileName
	 * @param obj
	 * @throws IOException 
	 * @throws FileNotFoundException 
	 */
	public static void createFileFromObject(String fileName, Object obj) throws FileNotFoundException, IOException{
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(fileName));
		oos.writeObject(obj);
		oos.close();
	}
}
